﻿@{
    Layout = null;
}
@using Entity;
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>订单页面</title>

    <link href="/Mjs/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css" />
    <link href="/Mjs/basic/css/demo.css" rel="stylesheet" type="text/css" />
    <link href="/Mjs/css/cartstyle.css" rel="stylesheet" type="text/css" />
    <link href="/Mjs/css/jsstyle.css" rel="stylesheet" type="text/css" />
    @*<script src="~/Mjs/js/address.js"></script>*@
    <script src="~/Scripts/jquery-1.7.1.min.js"></script>
    <script type="text/javascript">
        $(function () {
            GetProvince();
            $("#Area").change(function () { GetCity(); });
            $("#City").change(function () { GetDistrict(); });

            //新增收获地址
            $("#addAddress").click(function () {
                $("#add").submit();
            });

            //地址加载
            GetAddress();

            //新增地址
            add();

            //地址选择效果
            $("#Address").delegate('.user-addresslist', 'click', function () {
                $(this).addClass("defaultAddr").siblings().removeClass("defaultAddr");
                var a = $(this).find("span .province").html();
                var b = $(this).find("span .city").html();
                var c = $(this).find("span .dist").html();
                var d = $(this).find("span .street").html();
                var e = $(this).find("span .buy-user").html();
                var f = $(this).find("span .buy-phone").html();
                var g = $(this).find("span .mid").html();
                $("#holyshit268").find(".province").html(a);
                $("#holyshit268").find(".city").html(b);
                $("#holyshit268").find(".dist").html(c);
                $("#holyshit268").find(".street").html(d);
                $("#holyshit268").find(".buy-user").html(e);
                $("#holyshit268").find(".buy-phone").html(f);
                $("#J_Go").attr('href', '/pay/paying?id=' + g);
            });

            //地址编辑
            $("#Address").delegate('.editor', 'click', function () {
                $("#addAddress").attr('id', 'Updata').html("修改");
                $("#add").attr('action', '/pay/Upcha');
                $("#am-text-lg").html("修改地址");
                var a = $(this).parent().parent().find("span .mid").html();
                $("#adid").val(a);
                var $ww = $(window).width();
                //禁止遮罩层下面的内容滚动
                $(document.body).css("overflow", "hidden");

                $(this).addClass("selected");
                $(this).parent().addClass("selected");

                $('.theme-popover-mask').show();
                $('.theme-popover-mask').height($(window).height());
                $('.theme-popover').slideDown(200);
                //数据回显
                $.getJSON("/Pay/Ucha",
                    { id: a }
                  , function (data) {
                      $.each(data, function (i, item) {
                          $("#user-name").val(item["Name"]);
                          $("#user-phone").val(item["phone"]);
                          $("#user-intro").val(item["AddressValue"]);
                          $("#Area").find("option:selected").text(item["Saveid"]);
                          $("#City").find("option:selected").text(item["Cityid"]);
                          $("#County").find("option:selected").text(item["Countyid"]);
                      })
                  });

                $('.theme-poptit .close,.btn-op .close').click(function () {
                    $(document.body).css("overflow", "visible");
                    $('.theme-login').removeClass("selected");
                    $('.item-props-can').removeClass("selected");
                    $('.theme-popover-mask').hide();
                    $('.theme-popover').slideUp(200);
                    $("#addAddress").attr('id', 'addAddress').html("添加");
                    $("#am-text-lg").html("新增地址");
                    $("#add").attr('action', '/pay/pay');
                })
            })

            //修改地址
            $("#Updata").click(function () {

                $("#add").submit();
            });

        });

        function add() {
            var $ww = $(window).width();
            $('.theme-login').click(function () {
                $("#user-name").val("");
                $("#user-phone").val("");
                $("#user-intro").val("");
                $("#Area").find("option:selected").text("请选择");
                $("#City").find("option:selected").text("请选择");
                $("#County").find("option:selected").text("请选择");
                //禁止遮罩层下面的内容滚动

                $(document.body).css("overflow", "hidden");

                $(this).addClass("selected");
                $(this).parent().addClass("selected");

                $('.theme-popover-mask').show();
                $('.theme-popover-mask').height($(window).height());
                $('.theme-popover').slideDown(200);
            })

            $('.theme-poptit .close,.btn-op .close').click(function () {
                $(document.body).css("overflow", "visible");
                $('.theme-login').removeClass("selected");
                $('.item-props-can').removeClass("selected");
                $('.theme-popover-mask').hide();
                $('.theme-popover').slideUp(200);
            })
        }

        function GetAddress() {
            var ad = $("#Address li:first").clone();
            var j = 0;
            $("#Address").empty();
            $.getJSON("/Pay/Addressm", function (data) {
                if (data != null && data != "") {
                    $.each(data, function (i, item) {
                        ad.appendTo("#Address");
                        $("#Address").eq(i).find("span .buy-user").html(item["Name"]);
                        $("#Address").eq(i).find("span .mid").html(item["AddressId"]);
                        $("#J_Go").attr('href', '/pay/paying?id=' + item["AddressId"]);
                        $("#Address").eq(i).find(".del").attr('href', '/pay/DelAddress?id=' + item["AddressId"]);
                        $("#Address").eq(i).find("span .buy-phone").html(item["phone"]);
                        $("#Address").eq(i).find("span .province").html(item["Saveid"]);
                        $("#Address").eq(i).find("span .city").html(item["Cityid"]);
                        $("#Address").eq(i).find("span .dist").html(item["Countyid"]);
                        $("#Address").eq(i).find("span .street").html(item["AddressValue"]);
                    });
                    //默认地址加载
                    payAddtress();
                }
                //} else {
                //    $("#Address").empty();
                //}
                GetAdd();
            });

        }

        function GetAdd() {
            $.getJSON("/Pay/Address", function (data) {
                $.each(data, function (i, item) {
                    $("#Address li").eq(i).clone().appendTo("#Address");
                    $("#Address li").eq(i + 1).find("span .buy-user").html(item["Name"]);
                    $("#Address li").eq(i + 1).find("span .mid").html(item["AddressId"]);
                    $("#Address li").eq(i + 1).find(".del").attr('href', '/pay/DelAddress?id=' + item["AddressId"]);
                    $("#Address li").eq(i + 1).find("span .buy-phone").html(item["phone"]);
                    $("#Address li").eq(i + 1).find("span .province").html(item["Saveid"]);
                    $("#Address li").eq(i + 1).find("span .city").html(item["Cityid"]);
                    $("#Address li").eq(i + 1).find("span .dist").html(item["Countyid"]);
                    $("#Address li").eq(i + 1).find("span .street").html(item["AddressValue"]);
                    $("#Address li").eq(i + 1).find(".deftip").remove();
                    $("#Address li").eq(i + 1).find(".hidden").attr('href', '/pay/mAddress?id=' + item["AddressId"]).removeClass("hidden");
                    $("#Address li").eq(i + 1).removeClass("defaultAddr");
                });

            });
        }

        function GetProvince() {
            $("#Area").empty();//清空省份SELECT控件
            $.getJSON("/Pay/GetProvincelist", function (data) {
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["codeID"]).text(item["name"]).appendTo($("#Area"));
                })
                GetCity();
            });
        }

        function GetCity() {
            $("#City").empty();//清空城市SELECT控件
            $.getJSON(
            "/Pay/GetCitylist",
            { pid: $("#Area").val() },
            function (data) {
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["codeID"]).text(item["name"]).appendTo($("#City"));

                })
                GetDistrict();
            });

        }

        function GetDistrict() {
            $("#County").empty();//清空区县SELECT控件
            $.getJSON(
                "/Pay/GetCountylist",
                {
                    cid: $("#City").val()
                },
                function (data) {
                    $.each(data, function (i, item) {
                        $("<option></option>").val(item["codeID"]).text(item["name"]).appendTo($("#County"));
                    })
                });
        }

        function payAddtress() {
            var a = $("#Address li:first").find("span .province").html();
            var b = $("#Address li:first").find("span .city").html();
            var c = $("#Address li:first").find("span .dist").html();
            var d = $("#Address li:first").find("span .street").html();
            var e = $("#Address li:first").find("span .buy-user").html();
            var f = $("#Address li:first").find("span .buy-phone").html();
            $("#holyshit268").find(".province").html(a);
            $("#holyshit268").find(".city").html(b);
            $("#holyshit268").find(".dist").html(c);
            $("#holyshit268").find(".street").html(d);
            $("#holyshit268").find(".buy-user").html(e);
            $("#holyshit268").find(".buy-phone").html(f);
        }

    </script>
</head>
<body>
    <!--顶部导航条 -->
    <div class="am-container header">
        <ul class="message-l">
            <div class="topMessage">
                <div class="menu-hd">
                    <a href="#" target="_top" class="h">亲，请登录</a>
                    <a href="#" target="_top">免费注册</a>
                </div>
            </div>
        </ul>
        <ul class="message-r">
            <div class="topMessage home">
                <div class="menu-hd"><a href="#" target="_top" class="h">商城首页</a></div>
            </div>
            <div class="topMessage my-shangcheng">
                <div class="menu-hd MyShangcheng"><a href="#" target="_top"><i class="am-icon-user am-icon-fw"></i>个人中心</a></div>
            </div>
            <div class="topMessage mini-cart">
                <div class="menu-hd"><a id="mc-menu-hd" href="#" target="_top"><i class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong id="J_MiniCartNum" class="h">0</strong></a></div>
            </div>
            <div class="topMessage favorite">
                <div class="menu-hd"><a href="#" target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a></div>
        </ul>
    </div>

    <!--悬浮搜索框-->

    <div class="nav white">
        <div class="logo">
            <img src="/Mjs/images/logo.png" />
        </div>
        <div class="logoBig">
            <li>
                <img src="/Mjs/images/logobig.png" /></li>
        </div>

        <div class="search-bar pr">
            <a name="index_none_header_sysc" href="#"></a>
            <form>
                <input id="searchInput" name="index_none_header_sysc" type="text" placeholder="搜索" autocomplete="off">
                <input id="ai-topsearch" class="submit am-btn" value="搜索" index="1" type="submit">
            </form>
        </div>
    </div>

    <div class="clear"></div>
    <div class="concent">
        <!--地址 -->
        <div class="paycont">
            <div class="address">
                <h3>确认收货地址 </h3>
                <div class="control">
                    <div class="tc-btn createAddr theme-login am-btn am-btn-danger">使用新地址</div>
                </div>
                <div class="clear"></div>
                <ul id="Address">
                    <li class="user-addresslist defaultAddr" onclick="selectm()">
                        <div class="address-left">
                            <div class="user DefaultAddr">
                                <span class="buy-address-detail">
                                    <span class="mid" style="display: none;"></span>
                                    <span class="buy-user">艾迪 </span>
                                    <span class="buy-phone">15888888888</span>
                                </span>
                            </div>
                            <div class="default-address DefaultAddr">
                                <span class="buy-line-title buy-line-title-type">收货地址：</span>
                                <span class="buy--address-detail">
                                    <span class="province">湖北</span>
                                    <span class="city">武汉</span>
                                    <span class="dist">洪山</span>
                                    <span class="street">雄楚大道666号(中南财经政法大学)</span>
                                </span>
                            </div>
                            <ins class="deftip">默认地址</ins>
                        </div>
                        <div class="address-right">
                            <a href="/Mjs/person/address.html">
                                <span class="am-icon-angle-right am-icon-lg"></span></a>
                        </div>
                        <div class="clear"></div>

                        <div class="new-addr-btn">
                            <a href="#" class="hidden">设为默认</a>
                            <span class="new-addr-bar hidden">|</span>
                            <a href="#" class="editor">编辑</a>
                            <span class="new-addr-bar">|</span>
                            <a href="#" class="del">删除</a>
                        </div>
                    </li>
                </ul>

                <div class="clear"></div>
            </div>
            <!--订单 -->
            <div class="concent">
                <div id="payTable">
                    <h3>确认订单信息</h3>
                    <div class="cart-table-th">
                        <div class="wp">

                            <div class="th th-item">
                                <div class="td-inner">商品信息</div>
                            </div>
                            <div class="th th-price">
                                <div class="td-inner">单价</div>
                            </div>
                            <div class="th th-amount">
                                <div class="td-inner">数量</div>
                            </div>
                            <div class="th th-sum">
                                <div class="td-inner">金额</div>
                            </div>

                        </div>
                    </div>
                    <div class="clear"></div>
                    @foreach (CartItem car in ViewBag.Goods)
                    { 
                        <tr class="item-list">
                            <div class="bundle  bundle-last">

                                <div class="bundle-main">
                                    <ul class="item-content clearfix">
                                        <div class="pay-phone">
                                            <li class="td td-item">
                                                <div class="item-pic">
                                                    <a href="#" class="J_MakePoint">
                                                        <img src="/Images/@car.Img" class="itempic J_ItemImg"></a>
                                                </div>
                                                <div class="item-info">
                                                    <div class="item-basic-info">
                                                        <a href="#" class="item-title J_MakePoint" data-point="tbcart.8.11">@car.BookName</a>
                                                    </div>
                                                </div>
                                            </li>
                                            <li class="td td-price">
                                                <div class="item-price price-promo-promo">
                                                    <div class="price-content">
                                                        <em class="J_Price price-now">@car.Price</em>
                                                    </div>
                                                </div>
                                            </li>
                                        </div>
                                        <li class="td td-amount">
                                            <div class="amount-wrapper ">
                                                <div class="item-amount ">
                                                    <span class="phone-title">购买数量</span>
                                                    <div class="sl">
                                                        <span class="text_box">@car.Num</span>
                                                    </div>
                                                </div>
                                            </div>
                                        </li>
                                        <li class="td td-sum">
                                            <div class="td-inner">
                                                <em tabindex="0" class="J_ItemSum number">@(car.Num*car.Price)</em>
                                            </div>
                                        </li>

                                    </ul>
                                    <div class="clear"></div>

                                </div>
                        </tr>
                        <div class="clear"></div>
                    }
                </div>
            </div>
            <div class="clear"></div>
            <!--含运费小计 -->
            <div class="buy-point-discharge ">
                <p class="price g_price ">
                    合计（含运费） <span>¥</span><em class="pay-sum">@ViewBag.money</em>
                </p>
            </div>

            <!--信息 -->
            <div class="order-go clearfix">
                <div class="pay-confirm clearfix">
                    <div class="box">
                        <div tabindex="0" id="holyshit267" class="realPay">
                            <em class="t">实付款：</em>
                            <span class="price g_price ">
                                <span>¥</span> <em class="style-large-bold-red " id="J_ActualFee">@ViewBag.money</em>
                            </span>
                        </div>

                        <div id="holyshit268" class="pay-address">

                            <p class="buy-footer-address">
                                <span class="buy-line-title buy-line-title-type">寄送至：</span>
                                <span class="buy--address-detail">
                                    <span class="province">湖北</span>
                                    <span class="city">武汉</span>
                                    <span class="dist">洪山</span>
                                    <span class="street">雄楚大道666号(中南财经政法大学)</span>
                                </span>
                            </p>
                            <p class="buy-footer-address">
                                <span class="buy-line-title">收货人：</span>
                                <span class="buy-address-detail">
                                    <span class="buy-user">艾迪 </span>
                                    <span class="buy-phone">15871145629</span>
                                </span>
                            </p>
                        </div>
                    </div>

                    <div id="holyshit269" class="submitOrder">
                        <div class="go-btn-wrap">
                            <a id="J_Go" href="success.html" class="btn-go" tabindex="0" title="点击此按钮，提交订单">提交订单</a>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
            </div>
        </div>

        <div class="clear"></div>
    </div>
    @*尾部样式*@
    <div class="footer">
        <div class="footer-hd">
            <p>
                <a href="#">恒望科技</a>
                <b>|</b>
                <a href="#">商城首页</a>
                <b>|</b>
                <a href="#">支付宝</a>
                <b>|</b>
                <a href="#">物流</a>
            </p>
        </div>
        <div class="footer-bd">
            <p>
                <a href="#">关于恒望</a>
                <a href="#">合作伙伴</a>
                <a href="#">联系我们</a>
                <a href="#">网站地图</a>
            </p>
        </div>
    </div>
    <div class="theme-popover-mask"></div>
    @*新增收货地址*@
    <div class="theme-popover">

        <!--标题 -->
        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-danger am-text-lg " id="am-text-lg">新增地址</strong></div>
        </div>
        <hr />

        <div class="am-u-md-12">
            <form class="am-form am-form-horizontal" action="/Pay/pay" method="post" id="add">
                <input type="hidden" id="adid" name="AddressId" />
                <div class="am-form-group">
                    <label for="user-name" class="am-form-label">收货人</label>
                    <div class="am-form-content">
                        <input type="text" id="user-name" placeholder="收货人" name="Name">
                    </div>
                </div>

                <div class="am-form-group">
                    <label for="user-phone" class="am-form-label">手机号码</label>
                    <div class="am-form-content">
                        <input id="user-phone" placeholder="手机号必填" type="email" name="phone">
                    </div>
                </div>

                <div class="am-form-group">
                    <label for="user-phone" class="am-form-label">所在地</label>
                    <div class="am-form-content address">
                        <select id="Area" name="Saveid">
                            <option value="0">请选择</option>
                        </select>
                        <select id="City" name="Cityid">
                            <option value="0">请选择</option>
                        </select>
                        <select id="County" name="Countyid">
                            <option value="0">请选择</option>
                        </select>
                    </div>
                </div>

                <div class="am-form-group">
                    <label for="user-intro" class="am-form-label">详细地址</label>
                    <div class="am-form-content">
                        <textarea class="" rows="3" id="user-intro" placeholder="输入详细地址" name="AddressValue"></textarea>
                        <small>100字以内写出你的详细地址...</small>
                    </div>
                </div>

                <div class="am-form-group theme-poptit">
                    <div class="am-u-sm-9 am-u-sm-push-3">
                        <div id="addAddress" class="am-btn am-btn-danger">保存</div>
                        <div class="am-btn am-btn-danger close">取消</div>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div class="clear"></div>
</body>
</html>

